package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Enshrine;
import cn.wolfcode.trip.base.service.IEnshrineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/enshrine")
public class EnshrineController {

    @Autowired
    private IEnshrineService enshrineservice ;


    @GetMapping("/getMy/{userId}")
    public Object getEnshrine(@PathVariable Long userId){
        //查询到全部的数据
        return enshrineservice.selectMy(userId);
    }


    @GetMapping("/{userId}/dailys/{dailyId}")
    public int getDetail(@PathVariable Long userId,@PathVariable Long dailyId){
        return enshrineservice.selectForHave(userId,dailyId);
    }

    @GetMapping("/save/{userId}/{dailyId}")
    public Object save(@PathVariable Long userId,@PathVariable Long dailyId){
        Enshrine enshrine = new Enshrine();
        enshrine.setU_id(userId);
        enshrine.setD_id(dailyId);
        return enshrineservice.insert(enshrine);
    }

    @GetMapping("/delete/{userId}/{dailyId}")
    public Object delete(@PathVariable Long userId,@PathVariable Long dailyId){
        return enshrineservice.deleteByPrimaryKey(userId,dailyId);
    }
}
